package clustering.framework;

import java.util.Random;

public class Shuffle { 

    // swaps array elements i and j
    public static void exch(int[] a, int i, int j) {
    	int swap = a[i];
        a[i] = a[j];
        a[j] = swap;
    }

    // take as input an array of strings and rearrange them in random order
    public static void shuffle(int[] a) {
        int N = a.length;
        Random rand = new Random();
        
        for(int k=0;k<5;k++)
        {
	        for (int i = 0; i < N; i++) {
	            int r = i + (int) (Math.random() * (N-i));   // between i and N-1
	            exch(a, i, r);
	        }
        }
    }
}
